package register

import (
	"gitee.com/Hu-Lyndon/distill-resk/infra"
	"gitee.com/Hu-Lyndon/distill-resk/infra/utils"
	"github.com/micro/go-micro/v2"
	"github.com/micro/go-micro/v2/registry"
	"time"
)

var (
	microService  micro.Service
	microRegister registry.Registry
)

func MicroService() micro.Service {
	utils.Check(microService)
	return microService
}

func MicroRegister() registry.Registry {
	utils.Check(microRegister)
	return microRegister
}

type MicroStarter struct {
	infra.BaseStarter
}

func (m *MicroStarter) Init(ctx infra.StarterContext) {
	service := micro.NewService(
		micro.Name("go.micro.service.user"),
		micro.RegisterTTL(time.Second*10),     // 5s检查等待时间
		micro.RegisterInterval(time.Second*5), //服务每5s发一次心跳

		//micro.Registry(registry),
	)

	service.Init()
}

func (m *MicroStarter) Start(ctx infra.StarterContext) {

}
